﻿using System;
using System.Collections.Generic;
using System.Text;
using DataAccess;
using Entities;

namespace Logic
{
	public class ListBL
	{
		public bool Save(MovieList entity)
		{
			ListDAL dal = new ListDAL();
			return dal.Save(entity);
		}

		public bool Update(MovieList entity)
		{
			ListDAL dal = new ListDAL();
			return dal.Update(entity);
		}

		public bool AddMovie(MovieList entity, Movie movie)
		{
			ListDAL dal = new ListDAL();
			return dal.AddMovie(entity, movie);
		}

		public bool DeleteMovie(MovieList entity, Movie movie)
		{
			ListDAL dal = new ListDAL();
			return dal.DeleteMovie(entity, movie);
		}

		public bool Delete(MovieList entity)
		{
			ListDAL dal = new ListDAL();
			return dal.Delete(entity);
		}

		public List<MovieList> List()
		{
			ListDAL dal = new ListDAL();
			return dal.List();
		}

		public List<Movie> GetMovies(MovieList entity)
		{
			MovieDAL mdal = new MovieDAL();
			return mdal.List("SELECT movies.* FROM movies LEFT JOIN relationships ON movies.movie_id=relationships.movie_id WHERE relationships.relationship_element=" + entity.Id + " AND relationships.relationship_type='list'");
		}
	}
}